﻿// ImageDlg.cpp: 实现文件
//

#include "pch.h"
#include "3180101584SX1.h"
#include "ImageDlg.h"
#include "afxdialogex.h"

extern OpenImageClass OImageC;

// ImageDlg 对话框

IMPLEMENT_DYNAMIC(ImageDlg, CDialog)

ImageDlg::ImageDlg(CWnd* pParent /*=nullptr*/)
	: CDialog(IDD_DIALOG_IMAGE, pParent)
{

}

ImageDlg::~ImageDlg()
{
}

void ImageDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_TAB_IMAGE, m_tab);
}


BEGIN_MESSAGE_MAP(ImageDlg, CDialog)
	
	ON_NOTIFY(TCN_SELCHANGE, IDC_TAB_IMAGE, &ImageDlg::OnTcnSelchangeTabImage)
END_MESSAGE_MAP()


// ImageDlg 消息处理程序



BOOL ImageDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	m_tab.InsertItem(0, _T("1.打开图像"));
	m_OpenImageDlg.Create(IDD_DIALOG_OPENIMAGE, &m_tab);
	m_tab.InsertItem(1, _T("2.直方图统计"));
	m_ZFTDlg.Create(IDD_DIALOG_ZFT, &m_tab);
	m_tab.InsertItem(2, _T("3.散点图统计"));
	m_SDTDlg.Create(IDD_DIALOG_SDT, &m_tab);
	m_tab.InsertItem(4, _T("4.影像工具"));
	m_HAARDlg.Create(IDD_DIALOG_HAAR, &m_tab);
	m_tab.InsertItem(5, _T("5.转换工具"));
	m_ZHGJDlg.Create(IDD_DIALOG_ZHGJ, &m_tab);

	CRect tabrect;
	m_tab.GetClientRect(tabrect);

	tabrect.left += 1;
	tabrect.right -= 1;
	tabrect.top += 22;
	tabrect.bottom -= 1;

	m_OpenImageDlg.MoveWindow(&tabrect);
	m_ZFTDlg.MoveWindow(&tabrect);
	m_SDTDlg.MoveWindow(&tabrect);
	m_HAARDlg.MoveWindow(&tabrect);
	m_ZHGJDlg.MoveWindow(&tabrect);

	m_OpenImageDlg.ShowWindow(SW_SHOW);
	m_ZFTDlg.ShowWindow(SW_HIDE);
	m_SDTDlg.ShowWindow(SW_HIDE);
	m_HAARDlg.ShowWindow(SW_HIDE);
	m_ZHGJDlg.ShowWindow(SW_HIDE);

	return TRUE;  // return TRUE unless you set the focus to a control
				  // 异常: OCX 属性页应返回 FALSE
}





void ImageDlg::OnTcnSelchangeTabImage(NMHDR *pNMHDR, LRESULT *pResult)
{
	switch (m_tab.GetCurSel())
	{
	case 0:
		m_OpenImageDlg.ShowWindow(SW_SHOW);
		m_ZFTDlg.ShowWindow(SW_HIDE);
		m_SDTDlg.ShowWindow(SW_HIDE);
		m_HAARDlg.ShowWindow(SW_HIDE);
		m_ZHGJDlg.ShowWindow(SW_HIDE);
		break;
	case 1:
		m_OpenImageDlg.ShowWindow(SW_HIDE);
		m_ZFTDlg.ShowWindow(SW_SHOW);
		m_SDTDlg.ShowWindow(SW_HIDE);
		m_HAARDlg.ShowWindow(SW_HIDE);
		m_ZHGJDlg.ShowWindow(SW_HIDE);
		break;
	case 2:
		m_OpenImageDlg.ShowWindow(SW_HIDE);
		m_ZFTDlg.ShowWindow(SW_HIDE);
		m_SDTDlg.ShowWindow(SW_SHOW);
		m_HAARDlg.ShowWindow(SW_HIDE);
		m_ZHGJDlg.ShowWindow(SW_HIDE);
		break;
	case 3:
		m_OpenImageDlg.ShowWindow(SW_HIDE);
		m_ZFTDlg.ShowWindow(SW_HIDE);
		m_SDTDlg.ShowWindow(SW_HIDE);
		m_HAARDlg.ShowWindow(SW_SHOW);
		m_ZHGJDlg.ShowWindow(SW_HIDE);
		break;
	case 4:
		m_OpenImageDlg.ShowWindow(SW_HIDE);
		m_ZFTDlg.ShowWindow(SW_HIDE);
		m_SDTDlg.ShowWindow(SW_HIDE);
		m_HAARDlg.ShowWindow(SW_HIDE);
		m_ZHGJDlg.ShowWindow(SW_SHOW);
		break;
	default:
		break;
	}
	*pResult = 0;
}
